#ifndef __DISTSENSORLIB_H__
#define __DISTSENSORLIB_H__

#include <Arduino.h>


#include "SPI.h"

#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>

class DISTSENSORLib{
	public:
		
		float DistancePerRevolution_;
		int MaxHeight_;
		bool InvertRotationDirection_;

		bool StartSENSOR();
		byte GetDistance();
		int GetRepeticiones();
		
	private:
		
		bool	SEN5050;		//{SEN5050 = true SE USA AS5050, SEN5050 = false SE USA AS5055}
		byte INTERRUPTIONPIN;
		byte CSPIN;
		unsigned int result;
		unsigned int result1;
		unsigned int result2;
		unsigned int result3;
		unsigned int result4;
		float divisor;
		unsigned int mask;
		int LastAngle;
		int ActAngle;
		int LastPosition;
		int ActPosition;
		int LastDirection;
		int ActDirection;
		int TurnsCounter;
		int ReferenceAngle;
		int lecturas;
		bool firstReads;
		bool firstTime;
		

		bool ComprobandoSumaRepeticion;
		int MaximoRepeticion;
		int RepeticionesRealizadas;

};

#endif
